####################
#Replication information for:
#Newspaper Closures Polarize Voting Behavior
#Darr, Joshua P., Matthew P. Hitt, and Johanna L. Dunaway
#Journal of Communication
#Published online 11/5/2018
#If you use these data, please cite the original paper in the JOC
####################

#Load the necessary packages

require(Matching)
require(rbounds)
require(rgenoud)

#load DarrHittDunaway_Replication_Data_Final.RData 

#Bootstrapping requires some randomization 
#Expect to see slight perturbations in KS bootstrap p-values 
#due to randomization across repeated estimations

#To replicate Table 1

MatchBalance(treat_sen ~ compare_set_sen2$vap_total+ compare_set_sen2$age_median+ compare_set_sen2$female+ compare_set_sen2$households_medinc+ 
compare_set_sen2$somecol_25over+ compare_set_sen2$white_vap_pc+ compare_set_sen2$black_vap_pc+ compare_set_sen2$hisp_vap_pc+ compare_set_sen2$latitude+ compare_set_sen2$longitude+
compare_set_sen2$providers_yl08+ compare_set_sen2$pres_08_partisanship, match.out = mout, nboots = 10000)

#To replicate Table 2 

summary(mout)

#To replicate Table 3

psens(mout, Gamma=3, GammaInc=.1)

#To replicate Table 4

summary(mout.p)

#To replicate Table 5

summary(mout_roll)

